package com.yz.sharkim.entity.message.response;

import com.yz.sharkim.annotation.Id;
import com.yz.sharkim.entity.enums.CommonResult;
import com.yz.sharkim.entity.message.BaseMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author yangzheng
 * @version 1.0
 * @date 2019/11/4 10:38
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Id(BaseMessage.COMMON_RESPONSE)
public class CommonResponse extends BaseMessage {

    private int responseNo;

    private CommonResult result = CommonResult.SUCCESS;

    private String content;

    public CommonResponse(CommonResult result, String content) {
        this.result = result;
        this.content = content;
    }

    public static CommonResponse field(String content) {
        return new CommonResponse(CommonResult.FAILED, content);
    }

    public static CommonResponse success(String content) {
        return new CommonResponse(CommonResult.SUCCESS, content);
    }

    public static CommonResponse notSupport(String content) {
        return new CommonResponse(CommonResult.NO_SUPPORT, content);
    }

    public static CommonResponse success() {
        return success("");
    }

    public static CommonResponse notSupport() {
        return notSupport("");
    }
}
